

//需求:点击sign-input显示账号密码登录框,点击sign-sao显示扫码登录框

//获取元素
let signSao=document.querySelector('.sign-sao')
// console.log(signSao);
let signInput=document.querySelector('.sign-input')
// console.log(signInput);
let signZh=document.querySelector('.sign-zh')
// console.log(signZh);
let signSm=document.querySelector('.sign-sm')
// console.log(signSm);
let xiaXian=document.querySelector('.xiaxian')
// console.log(xiaXian);
let shuPsw=document.querySelector('.shu-psw')
// console.log(shuPsw);
let shuUser=document.querySelector('.shu-user')
// console.log(shuUser);
let signFalse=document.querySelector('.sign-false')
// console.log(signFalse);
let signFalse1=document.querySelector('.sign-false1')
let signBtn=document.querySelector('.sign-btn')
// console.log(signBtn);


// 需求:点击signSm切换到扫码登录,隐藏signInput

// 注册事件
signSm.addEventListener('click',function(){
    // console.log(123);
    signSao.style.display='block'
    signInput.style.display='none'
    signSm.style.color='#00bdff'
    signZh.style.color='#000'
    xiaXian.style.left='264px'

})

//需求:点击signZh切换到账号登录,隐藏signSao

signZh.addEventListener('click',function(){
    // console.log(456);
    signSao.style.display='none'
    signInput.style.display='block'
    signSm.style.color='#000'
    signZh.style.color='#00bdff'
    xiaXian.style.left='146px'
})



//需求:失焦验证,账号和密码的合法性

let userArr=/^[a-zA-Z]\w{5,11}$/;
let pswArr=/^[a-zA-Z]\w{5,11}$/;

shuUser.addEventListener('blur',function(){
    // console.log(123);
    let bool=userArr.test(shuUser.value)

    if(bool){
        signFalse.style.display='none'
    }else{
        signFalse.style.display='block'
    }
})


shuPsw.addEventListener('blur',function(){
    // console.log(123);
    let bool=userArr.test(shuPsw.value)

    if(bool){
        signFalse1.style.display='none'
    }else {
        signFalse1.style.display='block'
    }
})




//需求:点击signBtn,验证用户名密码合法性

signBtn.addEventListener('click',function(){
    // console.log(789);

    //判断
    if(userArr.test(shuUser.value)===false){
        signFalse.style.display='block'
    }else if(userArr.test(shuPsw.value===false)){
        signFalse1.style.display='block'
    }else{
        location.href='../page/彩蛋.html'
    }


})